<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/11/14
  Time: 13:53
  To change this template use File | Settings | File Templates.
--%>

<%@ page import="java.sql.Connection" %>
<%@ page import="cn.edu.xaut.utils.JDBCUtils" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="cn.edu.xaut.bean.UserBean" %>
<%@ page import="cn.edu.xaut.db.ConnDB" %>
<%@ page import="java.sql.SQLException" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户信息</title>
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="shortcut icon" href="#">
    <script src="js/jquery-3.5.1.js"></script>
    <script src="bootstrap-3.3.7-dist/js/bootstrap.js"></script>
</head>
<body>
<%
    /* 通过数据库获取学生信息 */
    UserBean userBean = new UserBean();
    int id = Integer.parseInt(request.getParameter("id"));
    try {
        String sql = "select * from dbmis.tb_student where id = " + id;
        ResultSet rs = ConnDB.query(sql);   // 执行查询操作
        if (rs.next()) {
            userBean.setId(id);
            userBean.setUsername(rs.getString("username"));
            userBean.setPassword(rs.getString("password"));
            userBean.setRealname(rs.getString("realname"));
            userBean.setTel(rs.getString("tel"));
            userBean.setEmail(rs.getString("email"));
            userBean.setCollege(rs.getString("college"));
        }

        ConnDB.close(); // 释放资源
    } catch (Exception e) {
        e.printStackTrace();
    }
%>

<div class="container">

    <div class="panel panel-primary">

        <div class="panel-heading">
            <h1 class="text-center">学生信息管理系统</h1>
        </div>

        <div class="panel-body">

            <form class="form-horizontal">

                <!-- 表单 -->
                <div class="form-group">
                    <label for="username" class="col-sm-2 control-label">用户名</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="username" readonly="true" value="<%=userBean.getUsername()%>">
                    </div>
                </div>

                <div class="form-group">
                    <label for="password" class="col-sm-2 control-label">密码</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="password" readonly="true" value="<%=userBean.getPassword()%>">
                    </div>
                </div>

                <div class="form-group">
                    <label for="realname" class="col-sm-2 control-label">姓名</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="realname" readonly="true" value="<%=userBean.getRealname()%>">
                    </div>
                </div>

                <div class="form-group">
                    <label for="tel" class="col-sm-2 control-label">手机号码</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="tel" readonly="true" value="<%=userBean.getTel()%>">
                    </div>
                </div>

                <div class="form-group">
                    <label for="email" class="col-sm-2 control-label">邮箱</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="email" readonly="true" value="<%=userBean.getEmail()%>">
                    </div>
                </div>

                <div class="form-group">
                    <label for="college" class="col-sm-2 control-label">学院</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="college" readonly="true" value="<%=userBean.getCollege()%>">
                    </div>
                </div>

                <div class="form-group text-center">
                    <button type="button" class="btn btn-info" id="back">返回</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    $(function () {
        $("#back").click(function () {
            window.location.href = "manage.jsp";
        })
    })
</script>
</body>
</html>
